{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "%matplotlib notebook"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "import xarray as xr\n",
    "import os"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "dir = r'C:\\Users\\apbarret\\Documents\\data\\SnowOnSeaIce'\n",
    "merra2fil = r'merra2_arctic_mean_prectot_arctic_ocean.nc'\n",
    "eraifil = r'era_interim_arctic_mean_prectot_arctic_ocean.nc'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<xarray.Dataset>\n",
       "Dimensions:  (ncl0: 36)\n",
       "Dimensions without coordinates: ncl0\n",
       "Data variables:\n",
       "    merra2   (ncl0) float64 ..."
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ds = xr.open_dataset(os.path.join(dir, merra2fil))\n",
    "ds"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<xarray.DataArray 'merra2' ()>\n",
      "array(274.800586)\n",
      "<xarray.DataArray 'merra2' ()>\n",
      "array(13.924813)\n",
      "<xarray.DataArray 'merra2' ()>\n",
      "array(246.565848) <xarray.DataArray 'merra2' ()>\n",
      "array(302.570236)\n"
     ]
    }
   ],
   "source": [
    "print (ds['merra2'].mean())\n",
    "print (ds['merra2'].std())\n",
    "print (ds['merra2'].min(), ds['merra2'].max())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<xarray.Dataset>\n",
       "Dimensions:  (ncl0: 35)\n",
       "Dimensions without coordinates: ncl0\n",
       "Data variables:\n",
       "    erai     (ncl0) float64 ..."
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "eds = xr.open_dataset(os.path.join(dir,eraifil))\n",
    "eds"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<xarray.DataArray 'erai' ()>\n",
      "array(219.468497)\n",
      "<xarray.DataArray 'erai' ()>\n",
      "array(13.934639)\n",
      "<xarray.DataArray 'erai' ()>\n",
      "array(184.38484) <xarray.DataArray 'erai' ()>\n",
      "array(242.715437)\n"
     ]
    }
   ],
   "source": [
    "print (eds['erai'].mean())\n",
    "print (eds['erai'].std())\n",
    "print (eds['erai'].min(), eds['erai'].max())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
